<?php
class skeleton {
	function skeleton() {
		$this->__construct();
	}
	
	function __construct() {
		$this->thing = get_class($this);
		$vars = array();
		foreach($this as $key => $value) $vars[preg_replace('/^'.preg_quote($this->thing.'_', '/').'/', '', $key)] = $value;
		foreach($vars as $key => $value) $this->$key = $value;
	}
	
	function get_id() {
		return $this->id;
	}
	
	function the_id() {
		echo $this->get_id();
	}
	
	function the_options() {
		$url = noun2plural($this->thing, 2).'.php';
		
		echo '<a href="'.$url.'?action=edit&amp;id='.$this->get_id().'" title="Edit"><img src="images/edit.png" alt="Edit" /></a>';
		if (!in_array($this->thing, array('user', 'category')) || $this->get_id() != 1) echo ' <a href="'.$url.'?action=delete&amp;id='.$this->get_id().'&amp;token='.substr(md5($_SESSION['token'].$this->get_id().SECRET), 0, 7).'" title="Delete" class="delete"><img src="images/delete.png" alt="Delete" /></a>';
		if ($this->thing == 'comment') {
			$action = ((bool)$this->status === true) ? 'unapprove' : 'approve';
			echo ' <a href="'.$url.'?action='.$action.'&amp;id='.$this->get_id().'" title="'.ucwords($action).'" class="status '.$action.'"><img src="images/'.$action.'.png" alt="'.ucwords($action).'" /></a>';
		}
	}
	
	function the_row_info() {
		if (!is_admin()) return false;
		
		echo ' id="'.$this->thing.'-'.$this->get_id().'" class="'.$this->thing.'"';
	}
}
?>